﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Top.Web;
using Top.Web.Api;
using Top.PointStore.Business.Models;

namespace Top.PointStore.Web.Filters
{

    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
    public class ProviderAttribute : Top.Web.Api.Filters.ApiFilterAttribute
    {
        public bool Check { get; private set; }
        public string Option { get; set; }

        public ProviderAttribute()
        {
            Check = true;
            Option = "";
        }
        public override bool AllowMultiple
        {
            get
            {
                return false;
            }
        }
        public ProviderAttribute(bool check)
        {
            Check = check;
        }

        public ProviderAttribute(string option)
        {
            Check = true;
            Option = option;
        }
        
        //public override object OnActionExecuting(IWebApi api)
        //{
        //    if (Check == false)
        //    {
        //        return null;
        //    }
            
        //    if (api.pUser != null)// && auth.AuthenticationType=="1"
        //    {
        //        if (api.pUser.PointStoreAuth.F_AuthorityID == 999)
        //        {
        //            return new WebApiException("供应商无此权限!");
        //        }               
        //    }
        //    return null;
        //}
    }
}